Skip to content

Add TOML configuration for default DNS nameservers, search, options#1614

Open
0xMH wants to merge 2 commits into
apple:mainfrom
0xMH:fix/1449-dns-defaults
Open

Add TOML configuration for default DNS nameservers, search, options#1614
0xMH wants to merge 2 commits into
apple:mainfrom
0xMH:fix/1449-dns-defaults

Conversation

@0xMH
Copy link
Copy Markdown
Contributor

@0xMH 0xMH commented May 28, 2026

Type of Change

  • New feature

Motivation and Context

Closes #1449. Adds default values for --dns, --dns-search, --dns-option, and --dns-domain to the [dns] section of ~/.config/container/config.toml, so users hitting macOS mDNSResponder conflicts can set the workaround once instead of repeating it on every invocation. Depends on the merged TOML configuration introduced by #1425.

Defaults are read by container run, container build, and container builder start via a shared Utility.dnsConfiguration(from:defaults:) helper. CLI flags take precedence; --no-dns still disables DNS. Two pre-existing bugs in the build path were fixed to make the feature work end-to-end: BuildCommand was forwarding only dnsNameservers to the builder (now forwards all four DNS fields), and BuilderStart's dnsChanged check only compared the first non-empty field (now compares all four).

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

}

final public class DNSConfig: Codable, Sendable {
public static let defaultNameservers: [String] = []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today there is a subtle difference between what the default DNS settings are for container aka the apiserver itself, which would determine the hostname resolution (aka the A record) for a given container on the host, and the DNS settings for setting up the resolv.conf in a container. I think we should maintain this distinction. There could be scenarios where a user does not want the default DNS domain on the host to necessarily match the default DNS domain that the container application uses in the container itself.

I think we should add a new field on the ContainerConfig type that has the default DNS settings for running a container.

Essentially we'd end up with something like this in the TOML:

[dns] <-------- default DNS settings for the APIServer
domain = "test"

[container.dns] <----------- default DNS settings for containers 
server = "8.8.8.8"
domain = "foo"
search = ["foo", "test"]
options = ["haha"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: system property for default --dns.

2 participants